﻿@{
    ViewBag.Title = "stedit";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <link href="~/Scripts/miniui/themes/default/default.css" rel="stylesheet" type="text/css" />       
}

<form id="form1" method="post">
    @Html.Partial("~/Views/Modular/Toolbars.cshtml")
    <div name="Base" title="门店资料" style="height:100%;overflow:hidden;margin-top:2px;margin-left:5px">
        <div title="基本信息" class="mini-panel" style="width:687px;height:180px;" buttons="">
            <table >
                <tr>
                    <td width="80px" height ="30px" align="right">商品编码：</td>
                    <td width="240px" height ="30px">
                        <input name="FNumber" id="FNumber" class="mini-textbox" style="width:240px;" readonly="readonly" enabled ="false" value="" TabIndex="1"/>
                    </td>
                    <td width="80px" height ="30px" align="right">商品分类：</td>
                    <td width="240px" height ="30px" colspan="3" >
                        <input name="FClassName" id="FClassName" class="mini-textbox" style="width:240px;" readonly="readonly" enabled ="false" value="" TabIndex="1"/>
                    </td>
                </tr>
                <tr>
                        <td width="80px" height ="30px" align="right">商品条码：</td>
                    <td width="240px" height ="30px">
                        <input id="FCode" name="FCode" class="mini-textbox " style="width:240px;" enabled ="false" TabIndex="2"/>
                    </td>
                        <td width="80px" height ="30px" align="right">所属商户：</td>
                    <td width="240px" height ="30px" colspan="3" >
                        <input name="FCorpName" id="FCorpName" class="mini-textbox" style="width:240px;" readonly="readonly" enabled ="false" value="" TabIndex="1"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="30px" align="right">商品名称：</td>
                    <td width="240px" height ="30px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:240px;" enabled ="false" TabIndex="2"/>
                    </td>
                    <td width="80px" height ="30px" align="right">规格型号：</td>
                    <td width="240px" height ="30px" colspan="3" >
                        <input id="FSpec" name="FSpec" class="mini-textbox " style="width:240px;" enabled ="false" TabIndex="3"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="30px" align="right">进货价：</td>
                    <td width="240px" height ="30px">
                        <input id="FPurPrice" name="FPurPrice" class="mini-spinner" changeOnMousewheel ="false" minValue="0" enabled ="false"  
                         maxValue="9999999" style="width: 240px;" TabIndex="6" format="#0.00"  showbutton="false" allowNull="true"/>                        
                    </td>
                    <td width="80px" height ="30px" align="right">单位：</td>
                    <td width="90px" height ="30px">
                        <input id="FUnitName" name="FUnitName" class="mini-textbox " enabled ="false"  style="width:90px;" TabIndex="4"/>
                    </td>
                    <td width="60px" height ="30px" align="right">内装数：</td>
                    <td width="90px" height ="30px">
                        <input id="FConvert" name="FConvert" class="mini-textbox " enabled ="false"  style="width:82px;" TabIndex="4"/>
                    </td>
                </tr>
             </table>
        </div>
        <div title="电商信息" class="mini-panel" style="width:687px;height:115px;" buttons="">
             <table >
                <tr>
                    <td width="80px" height ="30px" align="right">电商单位：</td>
                    <td width="130px" height ="30px">
                        <input id="FMallUnit" name="FMallUnit" class="mini-textbox " style="width:130px;" TabIndex="4"/>
                    </td>
                    <td width="80px" height ="30px" align="right">电商价：</td>
                    <td width="130px" height ="30px">
                        <input id="FMallPrice" name="FMallPrice" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="9999999"
                        style="width: 130px;" TabIndex="6" format="#0.00"  showbutton="false" allowNull="true"/>   
                    </td>
                    <td width="80px" height ="30px" align="right">电商内装数：</td>
                    <td width="130px" height ="30px">
                            <input id="FMallConvert" name="FMallConvert" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="9999999"
                             style="width: 130px;" TabIndex="6" format="#,0.00"  showbutton="false" allowNull="true"/>   
                    </td>
                </tr>
                <tr>

                    <td width="80px" height ="30px" align="right">电商热销：</td>
                    <td width="130px" height ="30px">
                        <input id="FHotSale" name="FHotSale" class="mini-combobox" style="width:130px;" showNullItem="false"
                                allowInput="false" align="left" value="1" data="comFlag" tabindex="12" />
                    </td>
                    <td width="80px" height ="30px" align="right">是否上架：</td>
                    <td width="130px" height ="30px">
                        <input id="FMallFlag" name="FMallFlag" class="mini-combobox" style="width:130px;" showNullItem="false"
                                allowInput="false" align="left" value="1" data="comFlag" tabindex="12" />
                    </td>
                    <td width="80px" height ="30px" align="right"></td>
                    <td width="130px" height ="30px">
                    </td>
                </tr>
            </table>
        </div>
        <div title="线下信息(提示：必须建独立价格方案才能修改)" class="mini-panel" style="width:687px;height:120px;" buttons="">
             <table >
                 <tr>
                    <td width="80px" height ="30px" align="right">库存上限：</td>
                    <td width="130px" height ="30px">                        
                            <input id="FHightLimit" name="FHightLimit" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="9999999"
                            style="width: 130px;" TabIndex="6" format="#,0.00"  showbutton="false" allowNull="true"/>  
                    </td>
                    <td width="80px" height ="30px" align="right">库存下限：</td>
                    <td width="130px" height ="30px">
                            <input id="FLowLimit" name="FLowLimit" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="9999999"
                            style="width: 130px;" TabIndex="6" format="#0.00"  showbutton="false" allowNull="true"/>   
                    </td>
                    <td width="80px" height ="30px" align="right">是否上架：</td>
                    <td width="130px" height ="30px">
                        <input id="FPosFlag" name="FPosFlag" class="mini-combobox" style="width:130px;" showNullItem="false"
                                allowInput="false" align="left" value="1" data="comFlag" tabindex="12" />
                    </td>
                 </tr>
                <tr>
                    <td width="80px" height ="30px" align="right">零售价：</td>
                    <td width="130px" height ="30px">
                            <input id="FPosPrice" name="FPosPrice" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="9999999"
                            style="width: 130px;" TabIndex="6" format="#0.00"  showbutton="false" allowNull="true"/>   
                    </td>
                    <td width="80px" height ="30px" align="right">会员价：</td>
                    <td width="130px" height ="30px">
                        <input id="FVipPrice" name="FVipPrice" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="9999999"
                        style="width: 130px;" TabIndex="6" format="#0.00"  showbutton="false" allowNull="true"/>    
                    </td>
                    <td width="80px" height ="30px" align="right"></td>
                    <td width="130px" height ="30px">
                        <div id="FShopPriceFlag" name="FShopPriceFlag" class="mini-checkbox" style="margin-right: 20px" readOnly="false" 
                        checked="false" text="启用分店价格" enabled ="false" onvaluechanged="setShopPriceFlag"></div>
                    </td>
                </tr>
              </table>
        </div>
    </div>
    <input name="FItemID" class="mini-hidden" />
    <input name="FPosPriceEntryID" class="mini-hidden" />
    <input name="FPosPriceBookID" class="mini-hidden" />
</form>

<script type="text/javascript">

    var comFlag = [{ "id": "0", "text": "否" },
                   { "id": "1", "text": "是" }]

    var comDeleted = [{ "id": "0", "text": "停用" },
                       { "id": "1", "text": "在售" }]

    mini.parse();

    function setShopPriceFlag() {
        if (mini.getbyName("FShopPriceFlag").checked == true) {
            mini.getbyName("FPosPrice").setEnabled(true);
            mini.getbyName("FVipPrice").setEnabled(true);
        }
        else {
            mini.getbyName("FPosPrice").setEnabled(false);
            mini.getbyName("FVipPrice").setEnabled(false);
        }
    }

    function setPosPriceState(row) {
        if (row.FPosPriceBookID <= 0) {
            mini.getbyName("FShopPriceFlag").setEnabled(false);
            mini.getbyName("FShopPriceFlag").setValue(false);
            mini.getbyName("FPosPrice").setEnabled(false);
            mini.getbyName("FVipPrice").setEnabled(false);            
        }
        else if (row.FPosPriceEntryID == 0) {
            mini.getbyName("FShopPriceFlag").setEnabled(true);
            mini.getbyName("FPosPrice").setEnabled(false);
            mini.getbyName("FVipPrice").setEnabled(false);
        }
        else {
            mini.getbyName("FShopPriceFlag").setValue(true);
        }
    }

    //加载资料
    function SetInfoData(row) {
        mini.getbyName("FPosPriceEntryID").setValue(row.FPosPriceEntryID);
        mini.getbyName("FPosPriceBookID").setValue(row.FPosPriceBookID);
        mini.getbyName("FItemID").setValue(row.FItemID);
        mini.getbyName("FNumber").setValue(row.FNumber);
        mini.getbyName("FCode").setValue(row.FCode);
        mini.getbyName("FName").setValue(row.FName);
        mini.getbyName("FSpec").setValue(row.FSpec);
        mini.getbyName("FClassName").setValue(row.FClassName);
        mini.getbyName("FUnitName").setValue(row.FUnitName);
        mini.getbyName("FConvert").setValue(row.FConvert);
        mini.getbyName("FMallUnit").setValue(row.FMallUnit);
        mini.getbyName("FMallFlag").setValue(row.FMallFlag);
        mini.getbyName("FPurPrice").setValue(row.FPurPrice);
        mini.getbyName("FPosPrice").setValue(row.FPosPrice);
        mini.getbyName("FVipPrice").setValue(row.FVipPrice);
        mini.getbyName("FMallPrice").setValue(row.FMallPrice);
        mini.getbyName("FMallConvert").setValue(row.FMallConvert);
        mini.getbyName("FCorpName").setValue(row.FCorpName);
        mini.getbyName("FHightLimit").setValue(row.FHightLimit);
        mini.getbyName("FLowLimit").setValue(row.FLowLimit);
        mini.getbyName("FHotSale").setValue(row.FHotSale);
        mini.getbyName("FPosFlag").setValue(row.FPosFlag);
        setPosPriceState(row);
    }

    //保存资料
    function SaveInfo() {
        var form = new mini.Form("#form1");
        form.validate();
        var data = form.getData(true, false);
        var json = mini.encode(data);
        mini.getbyName("SaveInfo").setEnabled(false);
        $.post("SaveGoodsMall", { json: json, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                //mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                CloseWindow('');
            }
            else {
                alert("异常 : " + ret.error);
            }
            mini.getbyName("SaveInfo").setEnabled(true);
        });
    }
</script>
